package com.example.controller;

import com.example.entity.ScheduleJobLogEntity;
import com.example.respdto.resultDTO;
import com.example.service.ScheduleJobLogService;
import com.example.util.PageUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 定时任务日志
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-05-30 22:54:41
 */
@RestController
@RequestMapping("generator/schedulejoblog")
public class ScheduleJobLogController {
    @Autowired
    private ScheduleJobLogService scheduleJobLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:schedulejoblog:list")
    public resultDTO list(@RequestParam Map<String, Object> params){
        PageUtils page = scheduleJobLogService.queryPage(params);
        return resultDTO.success(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{logId}")
    @RequiresPermissions("generator:schedulejoblog:info")
    public resultDTO info(@PathVariable("logId") Long logId){
		ScheduleJobLogEntity scheduleJobLog = scheduleJobLogService.getById(logId);

        return resultDTO.success(scheduleJobLog);

    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:schedulejoblog:save")
    public resultDTO save(@RequestBody ScheduleJobLogEntity scheduleJobLog){
		scheduleJobLogService.save(scheduleJobLog);
        return resultDTO.success(scheduleJobLog);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:schedulejoblog:update")
    public resultDTO update(@RequestBody ScheduleJobLogEntity scheduleJobLog){
		scheduleJobLogService.updateById(scheduleJobLog);
       return resultDTO.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:schedulejoblog:delete")
    public resultDTO delete(@RequestBody Long[] logIds){
		scheduleJobLogService.removeByIds(Arrays.asList(logIds));
        return  resultDTO.success();
    }

}
